const path = require('path')
const resolve = dir => path.join(__dirname, dir)

module.exports = {
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('assets', resolve('src/assets'))
      .set('common', resolve('src/common'))
      .set('components', resolve('src/components'))
      .set('network', resolve('src/network'))
      .set('views', resolve('src/views'))
  },
  devServer: {
    proxy: {     // see https://cli.vuejs.org/zh/config/#devserver-proxy
      '/api': {  // see https://github.com/chimurai/http-proxy-middleware#options
        target: 'http://localhost:8001', // target host
        pathRewrite: {'^/api' : ''},     // rewrite path
        ws: true,                        // proxy websockets
        changeOrigin: true               // needed for virtual hosted sites: when setting to true, the proxy server sets the host/port of the request header as the target site. 
      }
    }
  },
  lintOnSave: false
}